package backend.service.admin;

import backend.model.admin.Foreman;
import backend.service.base.DBModelServiceImpl;
import com.google.common.collect.Collections2;
import org.springframework.stereotype.Service;
import shared.other.Predicates;

import java.util.ArrayList;
import java.util.List;

@Service
public class ForemanServiceImpl extends DBModelServiceImpl<Foreman> implements  ForemanService {

    @Override
    public Class<Foreman> getEntityClass() {
        return Foreman.class;
    }

    @Override
    public List<Foreman> findAllForemen() {
        return dbModelDao.findByNamedQuery("findAllForemen");
    }

    @Override
    public List<Foreman> findAllActiveForemen() {
        List<Foreman> allForemen = dbModelDao.findByNamedQuery("findAllForemen");
        return new ArrayList<Foreman>(Collections2.filter(allForemen, Predicates.createActiveForemanPredicate()));
    }
}
